package com.woniuxy.mini;

import com.woniuxy.core.service.AllArticleService;
import com.woniuxy.core.service.AllTypeService;
import com.woniuxy.core.service.RelArticleTypeService;
import com.woniuxy.entity.AllType;
import com.woniuxy.entity.DTO.ArticleUserDTO;
import com.woniuxy.feign.AllUserAPI;
import com.woniuxy.util.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName RelArticleTypeController
 * @Description
 * @Author nanqiao
 * @Date 2025/7/12 10:09
 * @Version 1.0
 */
@RestController
@RequestMapping("/articletype")
public class RelArticleTypeController {

    @Autowired
    private RelArticleTypeService relArticleTypeService;
    @Autowired
    private AllTypeService allTypeService;
    @GetMapping("/type/{typeId}")
    public ResponseData<List<ArticleUserDTO>> getArticlesByTypeId(@PathVariable("typeId") Integer typeId) {
        List<ArticleUserDTO> articles = relArticleTypeService.getArticlesByTypeId(typeId);
        return ResponseData.ok(articles);
    }
    /**
     * 查询所有标签信息
     *
     * @return 标签列表
     */
    @GetMapping("/all")
    public ResponseData<List<AllType>> getAllTypes() {
        List<AllType> typeList = allTypeService.list();
        return ResponseData.ok(typeList);
    }
}